package leetcodecompetition.D346;

public class T6454 {
    public String makeSmallestPalindrome(String s) {
        int n = s.length();
        StringBuffer stringBuffer = new StringBuffer(s);
        for (int i = 0; i < n / 2; i++) {
            int c1 = stringBuffer.charAt(i);
            int c2 = stringBuffer.charAt(n - i - 1);
            if (c1 != c2) {
                char c = (char) Math.min(c1, c2);
                stringBuffer.setCharAt(i,c);
                stringBuffer.setCharAt(n - i - 1,c);
            }
        }
        return stringBuffer.toString();
    }
}
